<template>
    <div class="page-wrap">
        <div class="page-content" :style="{height:contentHei}">
            <div class="img-header">
                <div style="font-weight: 700;font-size: 18px">{{ pageTitle }}</div>
                <div style="display: flex;justify-content: flex-end;margin-bottom: 15px">
                    <Input style="width: 180px;margin-right: 15px" v-model.trim="searchSceneName" clearable @on-change="searchName" enter-button="搜索" placeholder="应用名称" />
                    <Button @click="refreshTem"><i class="el-icon-refresh-right" /></Button>
                </div>
            </div>
            <div>
            	<Table :columns="projectCol" :data="projectList" class="table-wrap"></Table>
                
            </div>
            <div style="display: flex;justify-content: center;margin: 15px 0" v-if="projectList.length > 0">
                <Page :total="proTotal" :page-size="proPageSize" @on-change="changePageNum" show-total  show-elevator/>
            </div>
        </div>

        <Drawer :closable="true" :mask-closable="true" width="1200"
                v-model="alarmModel" class="deviceDrawer" title="告警列表" @on-close="closeAlarmModel">
            <div style="position: absolute;top: 70px;left: -17px;cursor: pointer" @click="closeAlarmModel">
                <img src="../../assets/globalIcon/closeIcon.png" alt="Close">
            </div>
            <div style="display: flex;justify-content: flex-end;margin: 15px 0px">
                <i-select v-model="sceneRist" style="width: 150px;margin-right: 15px" @on-change="changeSceneRist">
                    <i-option value="all">所有状态</i-option>
                    <i-option value="low">低危</i-option>
                    <i-option value="medium">中危</i-option>
                    <i-option value="high">高危</i-option>
                </i-select>
                <Input v-model.trim="teamName" clearable style="width: 150px;margin-right: 15px" placeholder="团队名称" @on-change="searchTeamName"/>
                <Button @click="resetSearchAlarm"><i class="el-icon-refresh-right" /></Button>
            </div>
            <Table border :columns="alarmCol" :data="alarmList"></Table>
            <div style="display: flex;justify-content: center;margin: 15px 0">
                <Page :total="alarmTotal" @on-change="changeAlarmPageNum" show-total show-elevator :current="alarmPage"/>
            </div>
        </Drawer>

        <Drawer :closable="true" :mask-closable="true" width="1000"
                v-model="taskModel" class="deviceDrawer" title="任务列表">
            <div style="position: absolute;top: 70px;left: -17px;cursor: pointer" @click="closeDistribution">
                <img src="../../assets/globalIcon/closeIcon.png" alt="Close">
            </div>
            <div style="display: flex;justify-content: flex-end;margin: 15px 0">
                <i-select v-model="sceneStatus" style="width: 150px" @on-change="changeSceneStatus">
                    <i-option value="all">所有状态</i-option>
                    <i-option value="error">已停止</i-option>
                    <i-option value="initialized">初始化</i-option>
                    <i-option value="running">运行中</i-option>
                    <i-option value="completed">已完成</i-option>
                </i-select>
            </div>
            <Table border :columns="taskCol" :data="taskListData"></Table>
            <div style="display: flex;justify-content: center;margin: 15px 0">
                <Page :total="taskTotal" @on-change="changeTaskPageNum" show-total :current="taskPage" show-elevator/>
            </div>
        </Drawer>

        <Drawer :closable="true" :mask-closable="true" width="1000"
                v-model="scoreManageModel" class="deviceDrawer score-drawer" title="加减分管理">
            <div style="position: absolute;top: 70px;left: -17px;cursor: pointer" @click="scoreManageModel = false">
                <img src="../../assets/globalIcon/closeIcon.png" alt="Close">
            </div>
            <div class="score-manage-search">
                <Button @click="showScoreModal = true; scoreManageObj.activeType = 'add';">加减分</Button>
                <Select filterable v-model="scoreSearch.type" filterable clearable transfer placeholder="请选择加减分类型" @on-change="getScoreManageList(1)">
                    <Option :value="2" title="加分">加分</Option>
                    <Option :value="1" title="减分">减分</Option>
                </Select>
                <Select filterable v-model="scoreSearch.target" filterable clearable transfer placeholder="请选择目标" @on-change="getScoreManageList(1)">
                    <Option v-for="item in targetList" :value="item.id" :key="item.id" :title="item.company">{{ item.company }}</Option>
                </Select>
                <Select filterable v-model="scoreSearch.groupId" filterable clearable transfer placeholder="请选择团队" @on-change="getScoreManageList(1)">
                    <Option v-for="item in allTeamList" :value="item.id" :key="item.id" :title="item.name">{{ item.name }}</Option>
                </Select>
                <Button @click="resetSearch"><i class="el-icon-refresh-right" /></Button>
            </div>
            <Table border :columns="scoreCol" :data="scoreManageList"></Table>
            <div style="display: flex;justify-content: center;margin: 15px 0">
                <Page :total="scoreTotal" @on-change="getScoreManageList" show-total show-elevator :current="scoreSearch.page"/>
            </div>
        </Drawer>

        <Modal
            v-model="showScoreModal"
            @on-visible-change="visibleChange"
            title="加减分">
            <Form ref="scoreModal" :model="scoreManageObj" :rules="scoreModalRules" :label-width="100">
                <FormItem label="操作对象" prop="targetType">
                    <RadioGroup v-model="scoreManageObj.targetType" @on-change="scoreManageObj.groupId = '' ; scoreManageObj.target = ''">
                        <Radio :label="0" :disabled="scoreManageObj.activeType === 'update'">
                            <span>目标</span>
                        </Radio>
                        <Radio :label="1" :disabled="scoreManageObj.activeType === 'update'">
                            <span>团队</span>
                        </Radio>
                    </RadioGroup>
                </FormItem>
                <FormItem label="目标" v-if="scoreManageObj.targetType === 0" prop="target" key="target">
                    <Select filterable v-model="scoreManageObj.target" :disabled="scoreManageObj.activeType === 'update'"
                        filterable clearable transfer placeholder="">
                        <Option v-for="item in targetList" :value="item.id" :key="item.id" :title="item.company">{{ item.company }}</Option>
                    </Select>
                </FormItem>
                <FormItem label="团队" v-else prop="groupId" key="group">
                    <Select filterable v-model="scoreManageObj.groupId" :disabled="scoreManageObj.activeType === 'update'" 
                        filterable clearable transfer placeholder="">
                        <Option v-for="item in teamList" :value="item.id" :key="item.id" :title="item.name">{{ item.name }}</Option>
                    </Select>
                </FormItem>
                <FormItem label="加减分类型" prop="type">
                    <RadioGroup v-model="scoreManageObj.type">
                        <Radio :label="2">
                            <span>加分</span>
                        </Radio>
                        <Radio :label="1">
                            <span>减分</span>
                        </Radio>
                    </RadioGroup>
                </FormItem>
                <FormItem label="分值" prop="score">
                    <Input v-model="scoreManageObj.score" number></Input>
                </FormItem>
                <FormItem :label="`${scoreManageObj.type === 2 ? '加分' : '减分'}原因`" prop="approvalInfo">
                    <Input v-model="scoreManageObj.approvalInfo" :maxlength="200" type="textarea" :autosize="{minRows: 2,maxRows: 5}"></Input>
                </FormItem>
            </Form>
            <div slot="footer" class="footer">
                <Button type="text" size="large" @click="showScoreModal = false">取消</Button>
                <Button type="primary" size="large" @click="saveScoreManage" :loading="scoreManageObj.loading">确定</Button>
            </div>
        </Modal>
    </div>
</template>
<script>
    import $ from 'jquery'
    import {projectList,taskList,getScoreManageList,addScoreManage,updateScoreManage,deleteScoreManage,getAlarmList} from '@/api/referee.js'
    import { getTopoTargetList } from '@/api/drill_compete'
    import { getaccessgrouplist } from '@/api/access_new'
    export default {
    	components:{},
        data () {
            const validateScore = (rule,value,callback) => {
                if (value) {
                    if (!Number.isInteger(value)) {
                        callback(new Error('请输入整数'));
                    } else {
                        if (value < 0) {
                            callback(new Error('请输入正数'));
                        } else {
                            callback()
                        }
                    }
                } else {
                    callback(new Error('不能为空'));
                }
            }
            return {
                scoreModalRules: {
                    target: [
                        { required: true, message: '请选择目标', trigger: 'change' }
                    ],
                    groupId: [
                        { required: true, message: '请选择团队', trigger: 'change' }
                    ],
                    type: [
                        { required: true, type: 'number', message: '请选择加减分类型', trigger: 'change' }
                    ],
                    score: [
                        { required: true, validator: validateScore, trigger: 'change' },
                    ]
                },
                showScoreModal: false,
                scoreTotal: 0,
                targetList: [],
                teamList: [],
                allTeamList: [], // 包含管理员团队组
                scoreSearch: {
                    page: 1,
                    pageSize: 10,
                    type: '',
                    groupId: '',
                    target: ''
                },
                scoreManageObj: { // 添加、修改加减分的数据
                    targetType: 0, // 0目标  1团队
                    approvalInfo: '',
                    groupId: '',
                    target: '',
                    score: '',
                    type: 1,
                    loading: false,
                    activeType: 'add' // 区别是添加操作还是修改操作
                },
                scoreManageList: [],
                scoreManageModel: false,
                // 页面设置
                fullHeight: document.documentElement.clientHeight,
                fullWidth: document.documentElement.clientWidth,
                contentHei:'auto',
                // 工程列表
                proPage:1,
                proPageSize:12,
                projectList:[],
                proTotal:0,
                projectCol:[
//                  {
//                      type:'index',
//                      width:60,
//                  },
                    {
                        title:'应用名称',
                        key:'name',
                        minWidth:120,
                        placement:'top-left',
                    },
                    {
                        title:'类型',
                        key:'type',
                        width:120,
                        placement:'top-left',
                        render:(h,params)=>{
                            let text = ''
                            if(params.row.type === 0){
                                text='对抗演练'
                            }else if(params.row.type === 1){
                                text='攻防赛'
                            }else if(params.row.type === 2){
                                text='夺旗赛'
                            }else if(params.row.type === 3){
                                text='知识赛'
                            }else if(params.row.type === 4){
                                text='渗透演练'
                            }else if(params.row.type === 5){
                                text='护网'
                            }
                            return h('span',text)
                        }
                    },
                    {
                        title:'工程名称',
                        key:'projectname',
                        width:180,
                        tooltop:true,
                        tooltip:true
                    },
                    {
                        title:'创建者',
                        key:'creatorName',
                        width:100,
                        tooltop:true,
                    },
                    // {
                    //     title:'告警信息',
                    //     key:'task',
                    //     placement:'top-right',
                    //     render: (h, params) => {
                    //         return h('Button', {
                    //             props: {
                    //                 type:'info',
                    //                 ghost:true
                    //             },
                    //             on:{
                    //                 click:()=>{
                    //                     this.toAlarmPage(params.row)
                    //                 }
                    //             }
                    //         }, '告警详情');
                    //     }
                    // },
                    {
                        title:'任务列表',
                        key:'task',
//                      width:180,
                        placement:'top-right',
                        render: (h, params) => {
                            return h('Button', {
                                props: {
                                    type:'info',
                                    ghost:true
                                },
                                on:{
                                    click:()=>{
                                        this.toTaskPage(params.row)
                                    }
                                }
                            }, '详情');
                        }
                    },
                    {
                        title:'操作',
                        key:'active',
//                      width:180,
                        placement:'top-right',
                        render: (h, params) => {
                            return h('Button', {
                                props: {
                                    type:'info',
                                    ghost:true
                                },
                                on:{
                                    click:()=>{
                                        this.toScoreManagePage(params.row)
                                    }
                                }
                            }, '加减分管理');
                        }
                    },
                    {
                        title:'开始时间',
                        key:'starttime',
                        width:200,
                        sortable: true,//开启排序
                        sortType:"desc"//初始化排序
                    },
                    {
                        title:'结束时间',
                        key:'endtime',
                        width:200,
                    },
                ],
                searchSceneName:'',
                // 任务列表
                taskModel:false,
                proId:'',
                taskPage:1,
                taskPageSize:12,
                taskListData:[],
                taskTotal: 0,
                alarmCol:[
                    {
                        title:'序号',
                        type:'index',
                        width:60,
                    },
                    {
                        title:'攻击名称',
                        key: 'name',
                        ellipsis:true,
                        tooltip:true,
                    },
                    {
                        title:'队伍名称',
                        key: 'teamName',
                        ellipsis:true,
                        tooltip:true,
                    },
                    {
                        title:'攻击源IP',
                        key: 'src',
                        ellipsis:true,
                        tooltip:true,
                    },
                    {
                        title:'源端口',
                        key: 'sport',
                        ellipsis:true,
                        tooltip:true,
                    },
                    {
                        title:'攻击目标IP',
                        key: 'dst',
                        ellipsis:true,
                        tooltip:true,
                    },
                    {
                        title:'目标端口',
                        key: 'dport',
                        ellipsis:true,
                        tooltip:true,
                    },
                    {
                        title:'vlan',
                        key: 'vlan',
                        ellipsis:true,
                        tooltip:true,
                    },
                    {
                        title:'协议',
                        key: 'protocol',
                        ellipsis:true,
                        tooltip:true,
                    },
                    {
                        title:'威胁程度',
                        key:'risk',
                        render: (h, params) => {
                            return h('span', {
                            }, this.sceneRisk(params.row.risk));
                        }
                    },
                    {
                        title:'告警描述',
                        key: 'description',
                        ellipsis:true,
                        tooltip:true,
                    },
                    {
                        title:'时间',
                        key: 'createTime',
                        ellipsis:true,
                        tooltip:true,
                    },
                ],
                taskCol:[
                    {
                        title:'序号',
                        type:'index',
                        width:60,
                    },
                    {
                        title:'任务名称',
                        key:'name'
                    },
                    {
                        title:'创建者',
                        key:'creatorName'
                    },
                    {
                        title:'任务状态',
                        key:'status',
                        render: (h, params) => {
                            return h('span', {
                            }, this.sceneStatusFilter(params.row.status));
                        }
                    },
                    {
                        title:'查看报告',
                        key:'report',
                        render: (h, params) => {
                            return h('Button', {
                                props: {
                                    type:'primary',
                                    ghost:true
                                },
                                on:{
                                    click:()=>{
                                        this.toReportPage(params.row)
                                    }
                                }
                            }, '详情');
                        }
                    },
                    {
                        title:'描述',
                        key:'description'
                    },
                    {
                        title:'创建时间',
                        key:'created',
                        width:180,
                    },
                ],
                scoreCol: [
                    {
                        title: '目标',
                        key: 'targetName',
                        width: 138,
                        tooltip: true
                    },
                    {
                        title: '团队',
                        key: 'groupName',
                        width: 138,
                        tooltip: true
                    },
                    {
                        title: '操作类型',
                        key: 'type',
                        width: 138,
                        tooltip: true,
                        render: (h, params) => {
                            return h('span', params.row.type === 2 ? '加分' : '减分');
                        }
                    },
                    {
                        title: '分值',
                        key: 'score',
                        width: 138,
                        tooltip: true
                    },
                    {
                        title: '创建者',
                        key: 'creatorName',
                        width: 138,
                        tooltip: true
                    },
                    {
                        title: '原因',
                        key: 'approvalInfo',
                        width: 138,
                        tooltip: true
                    },
                    {
                        title: '操作',
                        key: 'active',
                        render: (h, params) => {
                            return h('div',[
								h('Button',{
									props:{
										type:'primary',
										size:'small'
									},
									style:{
										marginRight:'5px'
									},
									on:{
										click:()=>{
											this.showScoreModal = true
                                            this.scoreManageObj = Object.assign({
                                                targetType: params.row.target ? 0 : 1, // 0目标  1团队
                                                loading: false,
                                                activeType: 'update'
                                            }, params.row)
										}
									}
								},'修改'),
								h('Poptip', {
									props: {
										confirm: true,
										'ok-text': "确定",
										'cancel-text': "取消",
										type: 'error',
										size: 'large',
										title: '你确定要删除吗?',
										transfer:true
									},
									on: {
										'on-ok': () => {
											this.deleteScoreManage(params.row.id)
										}
									}
								}, [
									h('Button', {
										props: {
											type: 'error',
											size: 'small'
										},
										style: {
											marginRight: '5px'
										},
									}, '删除')
								]),
							])
                        }
                    }
                ],
                sceneStatus: 'running',
                alarmModel: false,
                alarmId:'',
                alarmName: '',
                alarmTotal: 0,
                alarmList:[],
                alarmPage:1,
                alarmPageSize: 12,
                sceneRist: 'all',
                teamName:'',
            }
    },
    computed: {
        pageTitle () {
            //当前菜单显示名
            return this.$store.getters.pageTitle;
        },
    },
        created(){

        },
        watch: {
            scoreManageModel(newValue) {
                if (!newValue) {
                    this.resetSearch(true)
                }
            },
        },
        mounted(){
            this.setStyle()
            $('.page-content .ivu-divider-horizontal').css({
                'margin':'0px'
            })
            window.onresize = () => {
                this.setStyle()
            }
            // 调用工程列表
            this.getProjectList()
        },
        methods:{
            visibleChange(type) {
                if (!type) {
                    this.scoreManageObj = this.$options.data().scoreManageObj
                    this.$refs.scoreModal.resetFields()
                }
            },
            // 重置条件并搜索
            resetSearch(noRefresh) {
                this.scoreSearch = {
                    page: 1,
                    pageSize: 10,
                    type: '',
                    groupId: '',
                    target: ''
                }
                if (!noRefresh) {
                    this.getScoreManageList()
                }
            },
            // 攻击方获取团队的数据，防守方获取靶标的数据，并综合为统一的数组用于使用
            getTargetList() {
                let { id, projectid } = this.currentTemplate
                Promise.all([getTopoTargetList({
                    ageIndex: 1,
                    pageSize: 2147483646,
                    projectId: projectid
                }), getaccessgrouplist({
                    pageIndex: 1,
                    pageSize: 2147483646,
                    testId: id,
                })]).then(res => {
                    if (res.some(item => item.code !== 1)) {
                        this.$Message.warning('获取团队、目标列表有误')
                    }
                    res.forEach((item, index) => {
                        if (item.code === 1) {
                            if (index === 0) { // 查询的是靶标
                                this.targetList = (item.data && item.data.items) || []
                            } else {
                                let list = (item.data && item.data.items) || []
                                this.adminTeam = list.find(item => item.creatorName === '内部服务用户') || {}
                                this.teamList = list.filter(item => item.creatorName !== '内部服务用户') || []
                                this.allTeamList = list
                            }
                        }
                    })
                }).catch(() => {
                    this.$Message.error('获取团队、目标列表异常')
                })
            },
            // 获取团队或者是目标的名称
            getOptionName(id, type) {
                let template = ((type === 0 ? this.targetList : this.teamList) || []).find(item => item.id === id)
                return template && template[type === 0 ? 'company' : 'name'] // 视情况获取不同的字段
            },
            // 获取加减分列表
            getScoreManageList(page) {
                if (page) {
                    this.scoreSearch.page = page
                }
                getScoreManageList(Object.assign(this.scoreSearch, { testId: this.currentTemplate.id })).then(({ data = {} }) => {
                    let { code, message } = data
                    data = data.data || {}
                    if (code !== 1) {
                        this.$Message.warning(message)
                        return
                    }
                    this.scoreTotal = data.totalCount || 0
                    this.scoreManageList = data.pageData || []
                }).catch(() => {
                    this.$Message.error('获取加减分列表异常')
                })
            },
            // 创建或修改数据
            saveScoreManage() {
                this.$refs.scoreModal.validate((valid) => {
                    if (valid) {
                        this.scoreManageObj.loading = true
                        let { id, name, projectid, projectname } = this.currentTemplate
                        let data = Object.assign(this.scoreManageObj, {
                            // 操作团队时查询团队名称，否则设置为undefined
                            groupName: this.scoreManageObj.targetType === 1 ? this.getOptionName(this.scoreManageObj.groupId, this.scoreManageObj.targetType) : undefined,
                            // 操作目标时查询目标名称，否则设置为undefined
                            targetName: this.scoreManageObj.targetType === 0 ? this.getOptionName(this.scoreManageObj.target, this.scoreManageObj.targetType) : undefined,
                            projectId: projectid,
                            projectName: projectname,
                            testId: id,
                            testName: name
                        })
                        if (this.scoreManageObj.targetType === 0) { // 针对目标加减分，需要补全团队Id、团队名称
                            data.groupId = this.adminTeam.id
                            data.groupName = this.adminTeam.name
                        }
                        let api = this.scoreManageObj.activeType === 'add' ? addScoreManage : updateScoreManage
                        let text = this.scoreManageObj.activeType === 'add' ? '添加' : '修改'
                        api(data).then(({ data = {} }) => {
                            let { code, message } = data
                            if (code !== 1) {
                                this.$Message.warning(message)
                                return
                            }
                            this.$Message.info(`${text}加减分成功`)
                            this.scoreManageObj.activeType === 'add' ? this.resetSearch() : this.getScoreManageList()
                            this.showScoreModal = false
                        }).catch(() => {
                            this.$Message.error(`${text}加减分异常`)
                        }).finally(() => {
                            this.scoreManageObj.loading = false
                        })
                    }
                })
            },
            // 删除加减分
            deleteScoreManage(id) {
                deleteScoreManage(id).then(({ data = {} }) => {
                    let { code, message } = data
                    if (code !== 1) {
                        this.$Message.warning(message)
                        return
                    }
                    this.$Message.info('删除成功')
                    if (this.scoreManageList.length === 1 && this.scoreSearch.page > 1) {
                        this.scoreSearch.page--
                    }
                    this.getScoreManageList()
                }).catch(() => {
                    this.$Message.error('删除加减分异常')
                })
            },
            sceneStatusFilter(val) {
                switch(val) {
                    case 'error': return '已停止'
                    case 'initialized': return '初始化'
                    case 'running': return '运行中'
                    case 'completed': return '已完成'
                    default: return '未知状态'
                }
            },

            sceneRisk(val) {
                switch(val) {
                    case 'low': return '低危'
                    case 'medium': return '中危'
                    case 'high': return '高危'
                    default: return '未知状态'
                }
            },
            setStyle(){
                window.fullHeight = document.documentElement.clientHeight;
                window.fullWidth = document.documentElement.clientWidth;
                this.fullHeight = window.fullHeight;
                this.fullWidth = window.fullWidth;
                this.contentHei =   this.fullHeight - 80 +'px'  // 80是头部高度  60是上下padding
            },
            // 获取工程列表
            getProjectList(){
                let params = {
                    page:this.proPage,
                    pageSize:this.proPageSize,
                }
                if(this.searchSceneName != ''){
                    params.name = this.searchSceneName
                }
                projectList(params)
                    .then(res=>{
                        if(res.data.code === 1){
                            this.projectList = res.data.data.pageData
                            this.proTotal = res.data.data.totalCount
                        }
                    })
                    .catch(err=>{
                    })
            },
            // 过滤
            changePageNum(val){
                this.proPage = val
                this.getProjectList()
            },
            searchName(val){
                this.searchSceneName = this.searchSceneName
                this.getProjectList()
            },
            refreshTem(){
                this.proPage = 1
                this.searchSceneName = ''
                this.getProjectList()
            },
            // 设置工程状态颜色
            setColor(status){
                let obj = {
                    color:'',
                    text:'',
                }
                switch (status){
                    case 0:  // 未部署
                        obj.color = '#888'
                        obj.text = '未部署'
                        return obj
                        break;
                    case 3:   // 部署成功
                        obj.color = '#06b649'
                        obj.text = '部署成功'
                        return obj
                        break;
                    case 4:   // 删除中
                        obj.color = '#ff4242'
                        obj.text = '删除中'
                        return obj
                        break;
                    case 6:   // '部署失败'
                        obj.color = '#ff4242'
                        obj.text = '部署失败'
                        return obj
                        break;
                    case 8:   // '删除失败'
                        obj.color = '#fa9901'
                        obj.text = '删除失败'
                        return obj
                        break;
                    case 9:   // '部署中'
                        obj.color = '#06b649'
                        obj.text = '部署中'
                        return obj
                        break;
                    case 12:   // '待删除'
                        obj.color = '#888'
                        obj.text = '待删除'
                        return obj
                        break;
                    case 13:   // '清空部署中'
                        obj.color = '#ff8244'
                        obj.text = '清空部署中'
                        return obj
                        break;
                    case 14:  // '清空部署失败'
                        obj.color = '#ff8244'
                        obj.text = '清空部署失败'
                        return obj
                        break;
                    case 16:   // '工程导入中'
                        obj.color = '#088cf0'
                        obj.text = '工程导入中'
                        return obj
                        break;
                    case 17:   // '工程导入失败'
                        obj.color = '#cb0236'
                        obj.text = '工程导入失败'
                        return obj
                        break;
                }
            },
            // 展示加减分管理页面，加载加减分列表，加载靶标、团队列表
            toScoreManagePage(row) {
                this.currentTemplate = row
                this.scoreManageModel = true
                this.getTargetList()
                this.getScoreManageList()
            },

            // 告警信息列表
            toAlarmPage (row) {
                this.alarmName = row.name
                this.alarmId = row.id
                this.getAlarmList()
                this.alarmModel = true
            },
            closeAlarmModel () {
                this.alarmName = ''
                this.alarmId = ''
                this.teamName = ''
                this.sceneRist = 'all'
                this.alarmModel = false
            },
            resetSearchAlarm () {
                this.teamName = ''
                this.sceneRist = 'all'
                this.alarmPage = 1
                this.alarmPageSize = 12
                this.getAlarmList()
            },
             changeAlarmPageNum (val) {
                 this.alarmPage = val
                 this.getAlarmList()
            },
            changeSceneRist (val) {
                this.sceneRist = val
                this.getAlarmList()
            },
            searchTeamName () {
                this.getAlarmList()
            },
            getAlarmList () {
                let params = {
                    pageIndex: this.alarmPage,
                    pageSize: this.alarmPageSize,
                    relativeld: this.alarmId,
                }
                if (this.sceneRist != 'all') {
                    params.risk = this.sceneRist
                } else {
                    delete params.risk
                }
                if (this.teamName) {
                    params.teamName = this.teamName
                } else {
                    delete params.teamName
                }
                getAlarmList(params).then(res => {
                    if (res.data.code == 1) {
                        this.alarmList = res.data.data.items
                        this.alarmTotal = res.data.data.total
                    } else {
                        this.alarmList = []
                        this.alarmTotal = 0
                    }
                }).catch(error => {
                    this.$Message.error(error)
                })
            },

            // 任务列表
            toTaskPage(row){
                this.proId = row.id
                this.taskName = row.name
                this.taskModel = true
                this.sceneStatus = 'running'
                this.taskList()
            },
            taskList(){
                let params = {
                    page:this.taskPage,
                    pageSize:this.taskPageSize,
                    testId:this.proId,
                    status:this.sceneStatus,
                }
                taskList(params)
                    .then(res=>{
                        if(res.data.code === 1){
                            this.taskListData = res.data.data.pageData
                            this.taskTotal = res.data.data.totalCount
                        }
                    })
                    .catch(err=>{
                    })
            },
            changeTaskPageNum(val){
                this.taskPage = val
                this.taskList()
            },
            changeSceneStatus(val){
                this.sceneStatus = val
                this.taskList()
            },
            // 跳转报告详情
            toReportPage(row){
                this.$router.push({
                    name: 'reportPage',
                    query:{
                        proId: this.proId,
                        taskId: row.id,
                        taskName: this.taskName
                    }
                })
            },
            closeDistribution(){
	        	this.taskModel = false;
	        }
        }
    }
</script>
<style scoped>
    .score-drawer .score-manage-search {
        display: flex;
        justify-content: flex-end;
        margin: 15px 0
    }
    .score-drawer .score-manage-search /deep/ .ivu-select {
        width: 150px;
    }
    .score-drawer .score-manage-search /deep/ .ivu-btn,
    .score-drawer .score-manage-search /deep/ .ivu-select {
        margin-left: 12px;
    }
    .score-drawer /deep/ .ivu-table {
        max-height: calc(100vh - 200px);
        overflow-y: auto;
    }
    .page-wrap{
        padding: 30px;
    }
    .page-content{
        background-color: #fff;
        border-radius: 10px;
    }
    .table-wrap{
        padding:0 20px;
        /*height: calc(100% - 94px);
        overflow-x: hidden;
        overflow-y: auto;*/
    }
    .table-wrap::-webkit-scrollbar{
        /*滚动条整体样式*/
        width: 8px; /*高宽分别对应横竖滚动条的尺寸*/
        height: 6px;
    }
    .table-wrap::-webkit-scrollbar-thumb{
        /*滚动条里面小方块样式*/
        border-radius: 5px;
        box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
        -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
        background: rgba(209, 209, 209,0.6);
    }
    .table-wrap::-webkit-scrollbar-track{
        /*滚动条里面轨道样式*/
        box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
        -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
        border-radius: 5px;
        background: rgba(179, 179, 179, 0.1);
    }
    .img-header{
        display: flex;
        justify-content: space-between;
        padding: 20px 20px 0 20px;
    }
    .deviceDrawer /deep/ .ivu-drawer-body{
		overflow: inherit;
	}
</style>
<style>
	#setOverflowDraw .ivu-drawer-body{
		overflow: inherit;
	}
</style>


